Option Explicit


' 检查任意类型参数 `v` 是否是一个字符串类型的数据
' @param v 一个任意类型的数据
' @return Boolean
Public Function isString(ByRef v As Variant) As Boolean
    isString = (VarType(v) = vbString)
End Function

' 检查任意类型参数 `v` 是否是一个数值类型的数据
'    以下类型的数据都会返回 `true`
'        Integer
'        Long
'        Decimal
'        Single
'        Double
' @param v 一个任意类型的数据
' @return Boolean
Public Function isNumber(ByRef v As Variant) As Boolean
    Dim dt As Integer
    dt = VarType(v)

    If dt = vbInteger Then
        isNumber = True
        Exit Function
    ElseIf dt = vbLong Then
        isNumber = True
        Exit Function
    ElseIf dt = vbSingle Then
        isNumber = True
        Exit Function
    ElseIf dt = vbDouble Then
        isNumber = True
        Exit Function
    ElseIf dt = vbDecimal Then
        isNumber = True
        Exit Function
    Else
        isNumber = False
        Exit Function
    End If
End Function

' 检查任意类型参数 `v` 是否是一个整型的数据
'    以下类型的数据都会返回 `true`
'      Single
'      Integer
'      Long
' @param v 一个任意类型的数据
' @return Boolean
Public Function isInt(ByRef v As Variant) As Boolean
    Dim dt As Integer
    dt = VarType(v)

    If dt = vbInteger Then
        isInt = True
        Exit Function
    ElseIf dt = vbLong Then
        isInt = True
        Exit Function
    Else
        isInt = False
        Exit Function
    End If
End Function

' 检查任意类型参数 `v` 是否是一个浮点型的数据
' @param v 一个任意类型的数据
'    以下类型的数据都会返回 `true`
'      Decimal
'      Single
'      Double
' @return Boolean
Public Function isFloat(ByRef v As Variant) As Boolean
    Dim dt As Integer
    dt = VarType(v)

    If dt = vbDecimal Then
        isFloat = True
        Exit Function
    ElseIf dt = vbSingle Then
        isFloat = True
        Exit Function
    ElseIf dt = vbDouble Then
        isFloat = True
        Exit Function
    Else
        isFloat = False
        Exit Function
    End If
End Function
